<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@page import="com.ks.app.navigate.hibernate.KsNavigate"%>
<%@ include file="/commons/taglibs.jsp" %>

<html>
  <head>
  
  	  <title>导航条管理</title>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />      
      <link href="${js}/thickbox.css" rel="stylesheet" type="text/css" />
      <script src="${js}/jqui/jquery-1.2.6.min.js" type="text/javascript"></script>
      <script src="${js}/json2-min.js" type="text/javascript"></script>
      <script src="${js}/jqtool.js" type="text/javascript"></script>
      <script src="${js}/ui.js" type="text/javascript"></script>
      <script src="${js}/thickbox-compressed.js" type="text/javascript"></script>
      <link href="${css}/Public.css"type="text/css" rel="stylesheet" />
      <link href="${css}/PublicEdit.css"type="text/css" rel="stylesheet" /> 
      <style type="text/css">

.STYLE1 {font-size: 12px}
.STYLE3 {font-size: 12px; font-weight: bold; }
.STYLE4 {	color: #03515d;
	font-size: 12px;
}
.dleft{
  width:60px;
  border:#FF0000 1px solid;
}
.dright{
  width:100px;
  border:green 1px solid;
}
.sortHead{
    background-image: url(${images}/updown.gif);
	background-repeat: no-repeat;
	background-position: center right;
	cursor: pointer;
}
.sortUp{
    background-image: url(${images}/desc.gif);
	background-repeat: no-repeat;
	background-position: center right;
	cursor: pointer;
}
.sortDown{
    background-image: url(${images}/asc.gif);
	background-repeat: no-repeat;
	background-position: center right;
	cursor: pointer;
}

#viewbox {
		position: absolute;
		left:320px;
		width: 450px;
		margin: 10px;
		padding: 20px 20px 20px;
		background: #eee;
		border: 2px solid #42CBDC;
}

      </style>
      <script language="javascript">     
      
	      $(window).bind('load', changeAct);
	      
	       function changeAct() {
	           $("#pno").change( function(){ 
		                            if( !isnumeric($("#pno"),"必须输入数字") ){
									    $("#pno").val("");
									    return;
									}
									if ( $("#pno").val() < 1 ){
									    alert("页码必须大于0");
										$("#pno").val("");
										$("#pno").focus();
										return;
									}
								 });
         	}
         	
			function toPage(){
			     if( $("#pno").val() == "" ){
				     alert("请输入页码");
					 $("#pno").focus();
					 return;
				 }			 
				 window.location.href = "ks_navigate_grid?pos=1&name=<urltag:encd input='${navigate.name}'/>&status=${navigate.status}&parentid=${navigate.parentid}&pno=" +  $("#pno").val();
			}	
			
			function delcfm()
			{
				    if(!confirm("确认要删除？"))
				    {
				        window.event.returnValue = false;
				        return;
				    }
			}
				
			function ToAddCmd()
			{			
					window.location.href = "edit_nav";
			}
			
		
		    function ChangeAll()
		    {
		    	 var dd=window.document.getElementById("selectall");
		    	 var chks=document.getElementsByTagName("input");
				     var len=chks.length;		   
				     for (i = 0; i < len; i++) 
				     {
				        var cur=chks[i];
				        if(cur.type=="checkbox")
				            {  				           
				            	{
					            	cur.checked=dd.checked;					            
					            }
					        }		          
				    }
		    }
		    
		     function checkall()
			 {
				 var checkall=document.getElementById("checkall");
			 	 var chks=document.getElementsByTagName("input");
			     var len=chks.length;		   
			     for (i = 0; i < len; i++) {
			        var cur=chks[i];
			        if(cur.type=="checkbox"&&cur.name!="checkall")
			            {
				            cur.checked=checkall.checked;			            
			            }		          
			    }
			 }
			 
		    function deleteData()
		    {
		     	 var idlist="";
				 var checkedNumber=0;
				 var chks=document.getElementsByTagName("input");
			     var len=chks.length;		   
			     for (i = 0; i < len; i++) {
			        var cur=chks[i];
			        if(cur.type=="checkbox"&&cur.name!="checkall")
			            {
				            if(cur.checked)
				            {
				            	checkedNumber++;
				            	idlist=idlist+cur.name+",";			            	
				            }
			            }		          
			     }
			//alert(idlist);
				if(checkedNumber>0)
				{
					//alert(checkedNumber);
					if(!confirm("确认要删除所选的"+checkedNumber+"条数据？"))
				    {
				        window.event.returnValue = false;
				        return;
				    }
			    }
			    else
			    {
			    	alert("请选择需要删除的项！");
			    	 window.event.returnValue = false;
			    	 return;
			    }
				if(idlist.length>1)
				{
					idlist=idlist.substring(0,idlist.length-1);
					var pno = "${PAGER.curPage}";
					var v="id="+idlist+"&pno="+pno;
				    window.location.href = "ks_del_navigate?"+v+"&pos=1&name=<urltag:encd input='${navigate.name}'/>&status=${navigate.status}&parentid=${navigate.parentid}";	
				}
		   // alert(idlist);
			
			}  
		
		 //更新导航条版本
		 function updateVer(){
		 	$.post(
					"${ctx}/updatewnav.action", 
					function(data) {	
						var json = JSON.parse(data);
						if(json.success){
							alert('版本升级成功！');
						};
					}
			);
		 }  
	  </script>
</head>
  <body marginheight="0" >
   <%
				            KsNavigate a = (KsNavigate)request.getAttribute("navigate"); 
				            int status = 0;
				            if(a != null){
				            	status = a.getStatus();
				            }             
	%>
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="30" background="${images}/tab_05.gif">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="12" height="30"><img src="${images}/tab_03.gif" width="12" height="30" /></td>
            <td>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="46%" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td width="5%"><div align="center"><img src="${images}/tb.gif" width="16" height="16" /></div></td>
                        <td width="95%" class="STYLE1"><span class="STYLE3">导航查询</span></td>
                      </tr>
                  </table></td><td width="54%" align="right">
                   <input type="button" onclick="ToAddCmd()" class="button2_60" name="addcmd" value="添加导航"></td>
              </tr>
            </table>            
            </td>
            <td width="16"><img src="${images}/tab_07.gif" width="16" height="30" /></td>
          </tr>
      </table>      
      </td>
    </tr>
    <tr>
      <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
            <td width="8" background="${images}/tab_12.gif">&nbsp;</td>
            <td>
           <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td valign="middle" class="STYLE1">
	                    
		                    <form name="qr" action="ks_navigate_grid" method="post">   
				                 <div class="l_f_body_row">
				                        <div class="l_f_body_div1">导航名称：</div>
				                        <div class="l_f_body_div5" >
						                	<input type="text" name="name" id="name" style="width: 130px" value="${navigate.name}"> &nbsp; 	                 		                   		      
						                </div>                      
				                 </div>
				                  <div class="l_f_body_row">
				                        <div class="l_f_body_div1">上级导航：</div>
				                        <div class="l_f_body_div5" >
						                	<select name="parentid" style="width: 78px"> 	
						                	
						                		<c:if test="${navigate.name==null}" >
					    							<option value="" selected="selected">全部</option>
					    							<c:forEach items="${plist}" var="p">
														<option value="${p.id}" >${p.name}</option>
													</c:forEach>
												</c:if>
												<c:if test="${navigate.name!=null}" >
													<option value="">全部</option>
													<c:forEach items="${plist}" var="p">
														<c:if test="${p.id==navigate.parentid}">
															<option value="${p.id}" selected="selected">${p.name}</option>
														</c:if>									
														<c:if test="${p.id!=navigate.parentid}">
															<option value="${p.id}" >${p.name}</option>
														</c:if>
													</c:forEach>
												</c:if>				
						                   </select>	                 		                   		      
						                </div>                      
				                 </div>	
				                 <div class="l_f_body_row">
				                        <div class="l_f_body_div1">上线状态：</div>
				                        <div class="l_f_body_div5" >			                        
						                    <input type="radio" name="status"  value="2" <%=(status==2)?"checked='checked'":"" %>/> 上线
						                    <input type="radio" name="status"  value="1" <%=(status==1)?"checked='checked'":"" %>/> 下线     							
			    							<input type="radio" name="status"  value="0" <%=(status==0)?"checked='checked'":"" %>/> 全部             		                   		      
						                </div>                      
				                 </div>							        		               		                 
				                 <div class="center l_f_body_foot">	
		                    	   <input type="submit" name="button"  style="border:solid 1px #ddf1fd;width:50;filter:progid:DXImageTransform.microsoft.gradient(startColorStr=#ddf1fd,endColorStr=#ddf1fd)" "   value="查询"> 
		                    	   <input type="button" name="button"  style="border:solid 1px #ddf1fd;width:50;filter:progid:DXImageTransform.microsoft.gradient(startColorStr=#ddf1fd,endColorStr=#ddf1fd)" onclick="deleteData();" value="删除">   
		                    	   <input type="button" name="button"  style="border:solid 1px #ddf1fd;width:100;filter:progid:DXImageTransform.microsoft.gradient(startColorStr=#ddf1fd,endColorStr=#ddf1fd)" onclick="updateVer();" value="版本升级">                  	                	  
		                         </div>
		                  </form>
                  </td>
              </tr>
            </table>
			        <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="b5d6e6" id="sort_table" >
			   			<tr id="sort_head">
			            		
					   			<td height="22" background="${images}/bg.gif" bgcolor="#FFFFFF"><div align="center" id="cb_name"><span class="STYLE1">全选<input type="checkbox" name="checkall" id="checkall" onclick="checkall()" ></span></div></td>                 			    
			            		<td height="22" background="${images}/bg.gif" bgcolor="#FFFFFF"><div align="center" id="cb_name"><span class="STYLE1">导航条名称</span></div></td>
								<td height="22" background="${images}/bg.gif" bgcolor="#FFFFFF"><div align="center" id="cb_sj"><span class="STYLE1">上级导航条</span></div></td>					
			            		<td height="22" background="${images}/bg.gif" width="30%" bgcolor="#FFFFFF"><div align="center" id="cb_wfc"><span class="STYLE1">导航条链接</span></div></td>			            	
			            		<td height="22" background="${images}/bg.gif" bgcolor="#FFFFFF"><div align="center" id="cb_xl"><span class="STYLE1">导航条状态</span></div></td>						
								<td height="22" background="${images}/bg.gif" bgcolor="#FFFFFF"><div align="center" id="cb_wxl"><span class="STYLE1">导航条优先级</span></div></td>
								
						 	    <td height="22" background="${images}/bg.gif" bgcolor="#FFFFFF"><div align="center" id="cb_Edit"><span class="STYLE1">修改</span></div></td>
								<td height="22" background="${images}/bg.gif" bgcolor="#FFFFFF"><div align="center" id="cb_Delete"><span class="STYLE1">删除</span></div></td>
						</tr> 
						
			            <c:forEach items="${list}" var="nav">
			                <tr> 			     	
			                	  <td height="22" bgcolor="#FFFFFF"><div align="center" ><span class="STYLE1"><input type="checkbox" name="${nav.id}" ></span></div></td>  
				  				  <td height="22" bgcolor="#FFFFFF"><div align="center" ><span class="STYLE1">${nav.name}</span></div></td>
				  				  <td height="22" bgcolor="#FFFFFF"><div align="center" ><span class="STYLE1">				  				 									    							
					    							<c:forEach items="${plist}" var="p">
														<c:if test="${p.id==nav.parentid}">${p.name}</c:if>
													</c:forEach>											
				  				  </span></div></td>   
			  					  <td height="22" bgcolor="#FFFFFF"><div align="center" ><span class="STYLE1">${nav.url}</span></div></td>  
			  					  <td height="22" bgcolor="#FFFFFF"><div align="center" ><span class="STYLE1">
			  					   		<c:if test="${nav.status==1}">下线</c:if>
		          						<c:if test="${nav.status==2}">上线</c:if></span></div>
			  					  </td>  
			  					  <td height="22" bgcolor="#FFFFFF"><div align="center" ><span class="STYLE1">${nav.ordernum}</span></div></td>  
			  					  
				                  <td height="22" bgcolor="#FFFFFF"><div align="center" id="cb_operate"><a href="edit_nav?id=${nav.id}&pno=${PAGER.curPage}&pos=1&name=<urltag:encd input='${navigate.name}'/>&status=${navigate.status}&parentid=${navigate.parentid}"><span class="STYLE1">修改</span></a></div></td>   
 								  <td height="22" bgcolor="#FFFFFF"><div align="center" id="cb_Delete"><a href="ks_del_navigate?id=${nav.id}&pno=${PAGER.curPage}&pos=1&name=<urltag:encd input='${navigate.name}'/>&status=${navigate.status}&parentid=${navigate.parentid}" onclick="delcfm()"><span class="STYLE1">删除</span></a></div></td>  
							</tr>
			           </c:forEach>
			         </table>
			         
          </td>
            <td width="8" background="${images}/tab_15.gif">&nbsp;</td>
          </tr>
      </table></td>
    </tr>
    <tr>
      <td height="35" background="${images}/tab_19.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="12" height="35"><img src="${images}/tab_18.gif" width="12" height="35" /></td>
            <td>
             <table width="100%" border="0" cellspacing="0" cellpadding="0">
               <tr>
                   <td class="STYLE4">&nbsp;&nbsp;共有 ${PAGER.totoalCnt} 条记录，当前第 ${PAGER.curPage}/${PAGER.totoalPage} 页</td>
                  <td><table border="0" align="right" cellpadding="0" cellspacing="0">
                      <tr>
                        <td width="40"><a href="ks_navigate_grid?pos=1&name=<urltag:encd input='${navigate.name}'/>&status=${navigate.status}&parentid=${navigate.parentid}"><img src="${images}/first.gif" width="37" height="15" border="0" /></a></td>
                        <td width="45"><a href="ks_navigate_grid?pno=${PAGER.prePage}&pos=1&name=<urltag:encd input='${navigate.name}'/>&status=${navigate.status}&parentid=${navigate.parentid}"><img src="${images}/back.gif" width="43" height="15" border="0" /></a></td>
                        <td width="45"><a href="ks_navigate_grid?pno=${PAGER.nextPage}&pos=1&name=<urltag:encd input='${navigate.name}'/>&status=${navigate.status}&parentid=${navigate.parentid}"><img src="${images}/next.gif" width="43" height="15" border="0" /></a></td>
                        <td width="40"><a href="ks_navigate_grid?pno=${PAGER.totoalPage}&pos=1&name=<urltag:encd input='${navigate.name}'/>&status=${navigate.status}&parentid=${navigate.parentid}"><img src="${images}/last.gif" width="37" height="15" border="0" /></a></td>
                        <td width="100"><div align="center"><span class="STYLE1">转到第
                          <input name="pno" id="pno" type="text" size="4" style="height:16px; width:20px; border:1px solid #999999;" />
                          页 </span></div></td>
                        <td width="40"><img src="${images}/go.gif" width="37" height="15"  style="cursor:hand" onClick="toPage();" border="0"/></td>
                      </tr>
                  </table></td>
                </tr>
            </table></td>
            <td width="16"><img src="${images}/tab_20.gif" width="16" height="35" /></td>
          </tr>
      </table>
      </td>
    </tr>
  </table>
</body>
</html>
